package com.lingyuan.product.service.impl;

import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lingyuan.product.config.ExcelUserExcelDTOListener;
import com.lingyuan.product.domain.UserExcel;
import com.lingyuan.product.mapper.UserMapper;
import com.lingyuan.product.service.UserService;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.apache.catalina.core.ApplicationContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;

/**
 * @ClassName UserServiceImpl
 * @Description 描述
 * @Author guoxin
 * @Date 2024/9/24 11:22
 */
@Service
@Log4j2
@Transactional(rollbackFor = Exception.class)
public class UserServiceImpl extends ServiceImpl<UserMapper, UserExcel>implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public void importData(InputStream inputStream) {
        EasyExcel.read(
                inputStream,
                UserExcel.class,
                new ExcelUserExcelDTOListener(userMapper)
        ).sheet().doRead();
        log.info("导入成功");
    }
}
